<#import "base/date.ftl" as dt>
package ${conf.base_package}.${conf.service_package}.impl;
<#-- beanName: supplier -->
<#assign beanName = table.beanName/>
<#-- beanName首字母大小:Supplier -->
<#assign beanNameUncap_first = beanName?uncap_first/>
<#assign propertysAndColumnInfos = table.propertysAndColumnInfos/>
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import ${conf.base_package}.${conf.bean_package}.${beanName};
import ${conf.base_package}.${conf.service_package}.I${beanName}Service;
import ${conf.base_package}.${conf.mapper_package}.${beanName}Mapper;
import java.util.List;
import ${conf.resp_package}.${beanName}Resp;
import ${conf.req_package}.${beanName}ListReq;
import ${conf.req_package}.${beanName}AddReq;
import ${conf.req_package}.${beanName}UpdateReq;

import com.gateon.hw.base.vo.Result;
import org.springframework.beans.BeanUtils;



/**
* ${table.tableDesc} ${beanName}ServiceImpl
* Created by ${conf.code_author} on ${.now}
*/
@Service
public class ${beanName}ServiceImpl implements I${beanName}Service{
    @Autowired
    private ${beanName}Mapper ${beanNameUncap_first}Mapper;

    @Override
    public ResultModel<IPage<${beanName}Resp>> list(${beanName}ListReq req) {
        Page page = new Page(req.getCurrentPage(), req.getPageSize());
        QueryWrapper<${beanName}> query = Wrappers.query();
        query.orderByDesc("id");
        IPage iPage = ${beanNameUncap_first}Mapper.selectPage(page, query);
        if (CollectionUtils.isEmpty(iPage.getRecords())) {
            return ResultUtil.success();
        }
        List<${beanName}Resp> responseList = ConvertDtoUtils.convertList(iPage.getRecords(), ${beanName}Resp.class);
        iPage.setRecords(responseList);
        return ResultUtil.success(iPage);
    }

    @Override
    public ResultModel<${beanName}Resp> detail(Long id) {
        ${beanName}Resp resp=new ${beanName}Resp();
        ${beanName} re=${beanNameUncap_first}Mapper.selectById(id);
        BeanUtils.copyProperties(re,resp);
        return ResultUtil.success(resp);
    }
    @Transactional
    @Override
    public ResultModel insert(${beanName}AddReq req) {
        ${beanName} re=new  ${beanName}();
        BeanUtils.copyProperties(req,re);
        ${beanNameUncap_first}Mapper.insert(re);
        return ResultUtil.success();
    }
    @Transactional
    @Override
    public ResultModel update(${beanName}UpdateReq req) {
        ${beanName} re=new  ${beanName}();
        BeanUtils.copyProperties(req,re);
        ${beanNameUncap_first}Mapper.updateById(re);
        return ResultUtil.success();
    }
    @Transactional
    @Override
    public ResultModel delete(Long  id) {
        ${beanNameUncap_first}Mapper.deleteById(id);
        return ResultUtil.success();
    }
}